﻿using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace Marmat.Forms
{
    [ToolboxItem(true)]
    public partial class PopupControl : PopupContainerControl
    {
        public PopupControl()
        {

            // 此调用是设计器所必需的。
            this.InitializeComponent();

            // 在 InitializeComponent() 调用之后添加任何初始化。
            this.SetStyle(ControlStyles.ContainerControl, true);
        }

        public new Control Parent
        {
            get
            {
                return this.OwnerEdit.Parent;
            }
        }

        [DefaultValue(null)]
        public object Value
        {
            get
            {
                object result = null;
                if (this.OwnerEdit is object)
                {
                    result = this.OwnerEdit.EditValue;
                }

                return result;
            }

            set
            {
                if (this.OwnerEdit is object)
                {
                    this.OwnerEdit.EditValue = value;
                }
            }
        }

        public void CloseDropDown()
        {
            if (this.OwnerEdit is object)
            {
                this.OwnerEdit.ClosePopup();
            }
        }
    }
}